<div class="row">
	<div class="col-md-12">
		<form id="paramAddForm" class="form-horizontal" action="${request.contextPath}/system/config/param/add" method="post" onsubmit="return false">
			<div class="box-body" >
				<div class="form-group">
					<label id="paramNameLabel" for="paramName" class="col-sm-1 control-label">名称</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" name="name" id="paramName" placeholder="输入名称...">
					</div>
					<label id="paramCodeLabel" for="paramCode" class="col-sm-1 control-label" >编码</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" name="code" id="paramCode" placeholder="输入编码...">
					</div>
				</div>
				<div class="form-group">
					<label id="paramValueLabel" for="paramValue" class="col-sm-1 control-label">字面值</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" name="value" id="paramValue" placeholder="输入参数值...">
					</div>
					<label id="paramSeqLabel" for="paramSeq" class="col-sm-1  control-label">排序号</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" name="seq" id="paramSeq" type="number" placeholder="输入排序号...">
					</div>
				</div>
				<div class="form-group">
					<label id="paramDescriptionLabel" class="col-sm-1 control-label" >描述</label>
					<div class="col-sm-11">
						<input type="text" class="form-control" name="description" id="paramDescription" placeholder="输入描述...">
					</div>
					</div>
				<div class="form-group">
					<label id="paramRemarkLabel" class="col-sm-1 control-label">备注</label>
					<div class="col-sm-11">
						<input type="text" class="form-control" name="remark" id="paramRemark" placeholder="输入备注...">
					</div>
				</div>
				<div class="error-message text-center" id="paramAddFormErrorMsgContainer">
					<span class="error-icon"></span>
					<span id="paramAddFormErrorMsg" class="error-msg" ></span>
				</div>
			</div>
			<div class="box-body">
				<div class="pull-right">
					<button type="submit" class="btn btn-primary btn-sm" ><i class="fa fa-save"></i> 保存</button>
					<button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><i class="fa fa-close"></i> 取消</button>
				</div>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">
function ajaxSubmit(form) {
	
	var $form = $(form);
	
	if ($form.length === 1 && $form.validate()) {
		$.post(form.action, $form.serialize(),
			function(result) {
				if (result.success) {
					$("#lgModal").modal('hide');
		        	alertMsg(result.message,"success");
		        	paramReload();
				} else {
					$form.find(".error-msg").show();
					$form.find(".error-msg").html(result.message);
				}
			}, 'json');
	}
}

$(function() {
	 
	$paramAddForm = $("#paramAddForm");
	$paramAddForm.validate({
		rules: {
			name: {
				required: true
			},
			code: {
				required: true
			},
			value: {
				required: true
			},
			description: {
				required: true
			},
			seq: {
				required: true
			}
		},
		messages: {
			name:{
				required:"名称不能为空！"
			},
			code:{
				required:"编码不能为空！"
			},
			value:{
				required:"参数值不能为空！"
			},
			description: {
				required: "描述不能为空！"
			},
			seq: {
				required: "排序号不能为空！"
			}
		},
		submitHandler:ajaxSubmit,
		errorLabelContainer:"#paramAddFormErrorMsgContainer",
		wrapper:"li",
		showErrors:function(errorMap,errorList) {
			if(errorList.length>0){
				$paramAddForm.find(".error-msg").html(errorList[0].message);
			}else{
				$paramAddForm.find(".error-msg").html("");
			}
		},
		onkeyup: false
	});
});
</script>